﻿/// <reference path="../libs/typedMVVM/include/typedMVVM.ts" />
/// <reference path="../libs/typedMVVM/include/win.ts" />

/// <reference path="../interfaces/IHomeViewModel.ts" />
/// <reference path="../interfaces/IViewModelFactory.ts" />
/// <reference path="../viewModels/HomeViewModel.ts" />
/// <reference path="../services/SampleService.ts" />
/// <reference path="../designData/services/SampleDesignDataService.ts" />
/// <reference path="../libs/typedMVVM/viewModels/IViewModelBase.ts" />

module TypedMVVM.Samples.ViewModels {
    // Provides logic for initialising ViewModel instances
    export class ViewModelFactory implements Interfaces.IViewModelFactory {
        // Returns an instance for the HomeViewModel
        // TODO: handle instances of ViewModels using IoC and integrate it with Navigation
        private static _homeViewModel: Interfaces.IHomeViewModel;
        public static get homeViewModel(): Interfaces.IHomeViewModel {
            if (!this._homeViewModel) {
                if (!Windows.ApplicationModel.DesignMode.designModeEnabled) {
                    this._homeViewModel = new HomeViewModel(Common.IoC.Container.resolve(Services.SampleService));
                }
                else {
                    //Inject Design-time data
                    this._homeViewModel = new HomeViewModel(Common.IoC.Container.resolve(DesignData.Services.SampleService));
                }                
            }
            return this._homeViewModel;
        }
        
        // ...
        // Initialises all other ViewModels
        // ...
    }
}
